package cn.trasen.his.poc.std.api.model.inpatient;

import cn.trasen.his.poc.std.api.emums.*;
import cn.trasen.his.poc.std.api.model.major.WardBed;
import cn.trasen.his.poc.std.api.model.major.GroupInfo;
import cn.trasen.his.poc.std.api.model.major.DeptInfo;
import cn.trasen.his.poc.std.api.model.major.WardInfo;
import pro.shushi.pamirs.boot.base.ux.annotation.field.UxWidget;
import pro.shushi.pamirs.boot.base.ux.annotation.view.UxDetail;
import pro.shushi.pamirs.boot.base.ux.annotation.view.UxForm;
import pro.shushi.pamirs.boot.base.ux.annotation.view.UxTableSearch;
import pro.shushi.pamirs.meta.annotation.Field;
import pro.shushi.pamirs.meta.annotation.Model;
import pro.shushi.pamirs.meta.base.IdModel;
import pro.shushi.pamirs.meta.enmu.NullableBoolEnum;

import java.util.Date;
import java.util.List;

/**
 * @Description: 住院病人登记表实体
 * @author: Jacob
 * @Date: 2024-12-6 13:47:02
 * @Company: 湖南创星科技股份有限公司
 */
// 模型中UX开头的注解(UxForm/UxTable/UxDetail等)可以不用写，都可在设计器中进行可视化配置; 代码里面写这些注解是为了默认页面的交互
@UxForm(grid = 3)
@UxDetail(grid = 3)
@Model.model(InpatientRecord.MODEL_MODEL)
@Model(displayName = "住院", labelFields = {"inpatientNo", "patientName"})
@Model.Advanced(unique = {"inpatientNo"}, index = {"bedNo"})
public class InpatientRecord extends IdModel {

    public static final String MODEL_MODEL = "ts.his.InpatientRecord";

    @UxTableSearch.FieldWidget(@UxWidget())
    @Field(displayName = "住院号")
    @UxForm.FieldWidget(@UxWidget(readonly = "true", hint = "系统自动生成"))
    @Field.Sequence(sequence = "DATE_ORDERLY_SEQ", prefix = "I", size = 4, initial = 0, format = "yyyyMMdd")
    private String inpatientNo;

    @UxTableSearch.FieldWidget(@UxWidget())
    @Field.many2one
    @Field.Relation(relationFields = {"visitId"}, referenceFields = {"id"})
    @Field(displayName = "就诊信息", required = true)
    private VisitRecord visitRecord;

    @Field.Integer
    @Field(displayName = "就诊信息ID", invisible = true)
    private Long visitId;

    @Field.String
    @Field.Related(related = {"visitRecord", "idCard"})
    @UxForm.FieldWidget(@UxWidget(readonly = "true"))
    @Field(displayName = "身份证")
    private String idCard;

    @Field.String
    @Field.Related(related = {"visitRecord", "patientName"})
    @UxForm.FieldWidget(@UxWidget(readonly = "true"))
    @Field(displayName = "患者姓名")
    private String patientName;

    @Field.Enum
    @Field.Related(related = {"visitRecord", "sex"})
    @UxForm.FieldWidget(@UxWidget(readonly = "true"))
    @Field(displayName = "性别")
    private SexTypeEnum sex;

    @Field.String
    @Field.Related(related = {"visitRecord", "age"})
    @UxForm.FieldWidget(@UxWidget(readonly = "true"))
    @Field(displayName = "年龄")
    private String age;

    @Field.String
    @Field.Related(related = {"visitRecord", "phone"})
    @UxForm.FieldWidget(@UxWidget(readonly = "true"))
    @Field(displayName = "联系方式")
    private String phone;

    @Field.String
    @Field.Related(related = {"visitRecord", "medicType"})
    @Field(displayName = "医保类型")
    private String medicType;

    @Field.Enum
    @Field(displayName = "人员类型")
    @UxForm.FieldWidget(@UxWidget(readonly = "true"))
    @Field.Related(related = {"visitRecord", "infantFlag"})
    private InfantFlagEnum infantFlag;

    @Field.String
    @UxForm.FieldWidget(@UxWidget(readonly = "true", invisible = "activeRecord.infantFlag!='BABY'"))
    @UxDetail.FieldWidget(@UxWidget(invisible = "activeRecord.infantFlag!='BABY'"))
    @Field.Related(related = {"visitRecord", "infantNum"})
    @Field(displayName = "婴儿编号")
    private String infantNum;

    @Field.many2one
    @Field.Relation(relationFields = {"deptId"}, referenceFields = {"id"}, domain = "deptType =='KE_SHI'")
    @Field(displayName = "科室", required = true)
    private DeptInfo deptInfo;

    @Field.Integer
    @Field(displayName = "科室ID", invisible = true)
    private Long deptId;

    //这个字段透出主要是MedicationAdvice能Related到
    @Field.String
    @Field(displayName = "科室名称", invisible = true, store = NullableBoolEnum.TRUE)
    @Field.Related(related = {"deptInfo", "name"})
    private String deptName;

    /////////////////////////////////////////////////
    @Field.Integer
    @Field(displayName = "母亲住院ID", invisible = true)
    private Integer motherId;

    @Field.String
    @Field(displayName = "紧急联系人")
    private String contactName;

    @Field.String
    @Field(displayName = "紧急联系人电话")
    private String contactPhone;

    @Field.many2one
    @Field.Relation(relationFields = {"wardId"}, referenceFields = {"id"})
    @Field(displayName = "病区名称", required = true)
    private WardInfo ward;

    @Field.Integer
    @Field(displayName = "病区ID", invisible = true)
    private Long wardId;

    //这个字段透出主要是MedicationAdvice能Related到
    @Field.String
    @Field(displayName = "病区名称", invisible = true)
    @Field.Related(related = {"ward", "name"})
    private String wardName;

    @Field.many2one
    @Field.Relation(relationFields = {"bedNo"}, referenceFields = {"bedNo"}, domain = "bedStatus =='0'")
    @Field(displayName = "床位", required = true)
    private WardBed wardBed;

    @Field.String
    @Field(displayName = "床位号", invisible = true)
    private String bedNo;

    @Field.Date
    @Field(displayName = "入院时间", required = true)
    private Date inDate;

    @Field.Date
    @Field(displayName = "出院时间")
    private Date outDate;

    @Field.Date
    @Field(displayName = "入区时间")
    private Date inAreaDate;

    @Field.Date
    @Field(displayName = "出区时间")
    private Date outAreaDate;

    @Field.many2one
    @Field.Relation(relationFields = {"belongGroupId"}, referenceFields = {"id"})
    @Field(displayName = "归属工作组名", required = true)
    private GroupInfo belongGroupName;

    @Field.Integer
    @Field(displayName = "归属工作组ID", invisible = true)
    private Long belongGroupId;

    @Field.String
    @Field(displayName = "管床医生ID", invisible = true)
    private String bedDocId;

    @Field.String
    @Field(displayName = "管床医生", required = true)
    private String bedDocName;

    @Field.String
    @Field(displayName = "管床护士", required = true)
    private String bedNurName;

    @Field.Enum
    @UxForm.FieldWidget(@UxWidget(invisible = "true"))
    @Field(displayName = "患者状态", defaultValue = "SIGN_NEW_IN_HOSP")
    private InpatientStatusEnum status;

    @Field.one2many
    @Field.Relation(relationFields = {"id"}, referenceFields = {"inpatientId"})
    @Field(displayName = "护理对象")
    private List<InpatientHl> inpatientHl;

    @Field.one2many
    @Field.Relation(relationFields = {"id"}, referenceFields = {"inpatientId"})
    @Field(displayName = "关注对象")
    private List<InpatientFollow> inpatientFollow;

    @Field.Integer
    @Field(displayName = "住院次数", invisible = true)
    private Integer inTimes;

    @Field.Integer
    @Field(displayName = "危急值")
    private Long danger;

    @Field.String
    @UxForm.FieldWidget(@UxWidget(span = 3))
    @UxDetail.FieldWidget(@UxWidget(span = 3))
    @Field.Related(related = {"visitRecord", "curDiagnosisName"})
    @Field(displayName = "诊断", required = true)
    private String curDiagnosisName;

    //////////////////////////FIXME：逻辑需要修改///////////////////////////
    @Field.Enum
    @Field(displayName = "护理级别", required = true)
    private InpatientTendLevelEnum tendLevel;

    @Field.Enum
    @Field(displayName = "床头标签", multi = true)
    private List<InpatientLabelEnum> inpatientLabel;

    @Field.Enum
    @Field(displayName = "病人状态", required = true)
    private PatBedCardStatusEnum patBedCardStatus;

    @Field.Enum
    @Field(displayName = "在院状态(模拟数据：床位卡状态)", required = true)
    private InHospitalStatusEnum inHospitalStatus;

}
